package com.example.siyun.controller.commentcontroller;

import com.example.siyun.pojo.SyComment;
import com.example.siyun.service.commentservice.CommentMicrocircleService;
import com.example.siyun.util.JsonResult;
import com.example.siyun.util.PageResult;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * 微圈评论
 *@author：王浩宇
 *@Date: 2022-10-12
 * */
@RestController
@RequestMapping("/microcircle")
@Slf4j
public class CommentMicrocircleController {



    @Autowired
    private CommentMicrocircleService commentMicrocircleService;

    /**
     * 获取全部课程评论
     * @page:页数
     * @limit:条数
     * */
    @RequestMapping("/get")
    public PageResult<List> get(Integer page, Integer limit){

        PageHelper.startPage(page, limit);
        List<SyComment> all = commentMicrocircleService.Get();

        PageInfo<SyComment> pageInfo = new PageInfo<>(all);

        PageResult<List> pageResult = new PageResult<>();
        pageResult.setMessage("成功");
        pageResult.setData(pageInfo.getList());
        pageResult.setState(0);
        pageResult.setTotal(pageInfo.getTotal());

        return pageResult;
    }
    /**
     *通过
     * @id:主键id
     * */
    @RequestMapping("/adopt")
    public void updateadopt(Integer id){
        commentMicrocircleService.updateAdopt(id);
        log.info(id+"状态改为通过");
    }
    /**
     *拦截
     *@id:主键id
     * */
    @RequestMapping("/intercep")
    public void updateintercep(Integer id){
        commentMicrocircleService.updateIntercept(id);
        log.info(id+"状态改为拦截");
    }
    /**
     *删除
     *@id:主键id
     * */
    @RequestMapping("/delete")
    public void updatedelete(Integer id){
        commentMicrocircleService.updateDelete(id);
        log.info(id+"状态改为删除");
    }
    /**
     *历史评论次数
     * */
    @RequestMapping("/countAll")
    public JsonResult<Integer> count(){
        int a = commentMicrocircleService.Count();

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *已通过全部评论
     * @page:页数
     * @limit:条数
     * */
    @RequestMapping("/getadopt")
    public PageResult<List> getByadopt(Integer page, Integer limit){

        PageHelper.startPage(page, limit);
        List<SyComment> all = commentMicrocircleService.getAdopt();

        PageInfo<SyComment> pageInfo = new PageInfo<>(all);

        PageResult<List> pageResult = new PageResult<>();
        pageResult.setMessage("成功");
        pageResult.setData(pageInfo.getList());
        pageResult.setState(0);
        pageResult.setTotal(pageInfo.getTotal());

        return pageResult;
    }
    /**
     *已通过全部历史评论次数
     * */
    @RequestMapping("/countadopt")
    public JsonResult<Integer> countByadopt(){
        int a = commentMicrocircleService.countAdopt();

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *已拦截全部评论
     * @page:页数
     * @limit:条数
     * */
    @RequestMapping("/getintercept")
    public PageResult<List> getByintercept(Integer page, Integer limit){

        PageHelper.startPage(page, limit);
        List<SyComment> all = commentMicrocircleService.getIntercept();

        PageInfo<SyComment> pageInfo = new PageInfo<>(all);

        PageResult<List> pageResult = new PageResult<>();
        pageResult.setMessage("成功");
        pageResult.setData(pageInfo.getList());
        pageResult.setState(0);
        pageResult.setTotal(pageInfo.getTotal());

        return pageResult;
    }
    /**
     *已拦截全部历史评论次数
     * */
    @RequestMapping("/countintercept")
    public JsonResult<Integer> countByintercept(){
        int a = commentMicrocircleService.countIntercept();

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *已删除全部评论
     * @page:页数
     * @limit:条数
     * */
    @RequestMapping("/getdelete")
    public PageResult<List> getBydelete(Integer page, Integer limit){

        PageHelper.startPage(page, limit);
        List<SyComment> all = commentMicrocircleService.getDelete();

        PageInfo<SyComment> pageInfo = new PageInfo<>(all);

        PageResult<List> pageResult = new PageResult<>();
        pageResult.setMessage("成功");
        pageResult.setData(pageInfo.getList());
        pageResult.setState(0);
        pageResult.setTotal(pageInfo.getTotal());

        return pageResult;
    }
    /**
     *已删除全部历史评论次数
     * */
    @RequestMapping("/countdelete")
    public JsonResult<Integer> countBydelete(){
        int a = commentMicrocircleService.countDelete();

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *历史评论人数
     * */
    @RequestMapping("/countpeople")
    public JsonResult<Integer> counttwo(){
        int a = commentMicrocircleService.countPeople();

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *已通过全部历史评论人数
     * */
    @RequestMapping("/countpeopleadopt")
    public JsonResult<Integer> counttwoByadopt(){
        int a = commentMicrocircleService.countPeopleAdopt();

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *已拦截全部历史评论人数
     * */
    @RequestMapping("/countpeopleintercept")
    public JsonResult<Integer> counttwoByintercept(){
        int a = commentMicrocircleService.countPeopleIntercept();

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *已删除全部历史评论人数
     * */
    @RequestMapping("/countpeopledelete")
    public JsonResult<Integer> counttwoBydelete(){
        int a = commentMicrocircleService.countPeopleDelete();

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *今日评论次数
     * */
    @RequestMapping("/counttoday")
    public JsonResult<Integer> countthree(){
        Calendar calendar = Calendar.getInstance(); // get current instance of the calendar
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String b = formatter.format(calendar.getTime());
        int a = commentMicrocircleService.countToday(b);

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *今日评论人数
     * */
    @RequestMapping("/counttodaypeople")
    public JsonResult<Integer> countfour(){
        Calendar calendar = Calendar.getInstance(); // get current instance of the calendar
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String b = formatter.format(calendar.getTime());
        int a = commentMicrocircleService.countTodayPeople(b);

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }

    /**
     *已通过今日评论次数
     * */
    @RequestMapping("/counttodayadopt")
    public JsonResult<Integer> countthreeByadopt(){
        Calendar calendar = Calendar.getInstance(); // get current instance of the calendar
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String b = formatter.format(calendar.getTime());
        int a = commentMicrocircleService.countTodayAdopt(b);

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *已通过今日评论人数
     * */
    @RequestMapping("/counttodaypeopleadopt")
    public JsonResult<Integer> countfourByadopt(){
        Calendar calendar = Calendar.getInstance(); // get current instance of the calendar
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String b = formatter.format(calendar.getTime());
        int a = commentMicrocircleService.countTodayPeopleAdopt(b);

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *已拦截今日评论次数
     * */
    @RequestMapping("/counttodayintercept")
    public JsonResult<Integer> countthreeByintercept(){
        Calendar calendar = Calendar.getInstance(); // get current instance of the calendar
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String b = formatter.format(calendar.getTime());
        int a = commentMicrocircleService.countTodayIntercept(b);

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *已拦截今日评论人数
     * */
    @RequestMapping("/counttodaypeopleintercept")
    public JsonResult<Integer> countfourByintercept(){
        Calendar calendar = Calendar.getInstance(); // get current instance of the calendar
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String b = formatter.format(calendar.getTime());
        int a = commentMicrocircleService.countTodayPeopleIntercept(b);

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *已删除今日评论次数
     * */
    @RequestMapping("/counttodaydelete")
    public JsonResult<Integer> countthreeBydelete(){
        Calendar calendar = Calendar.getInstance(); // get current instance of the calendar
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String b = formatter.format(calendar.getTime());
        int a = commentMicrocircleService.countTodayDelete(b);

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *已删除今日评论人数
     * */
    @RequestMapping("/counttodaypeopledelete")
    public JsonResult<Integer> countfourBydelete(){
        Calendar calendar = Calendar.getInstance(); // get current instance of the calendar
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String b = formatter.format(calendar.getTime());
        int a = commentMicrocircleService.countTodayPeopleDelete(b);

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *前端用户全部评论
     * @page:页数
     * @limit:条数
     * */
    @RequestMapping("/reception")
    public PageResult<List> reception(Integer page, Integer limit){
        Map<String, Object> map = new HashMap<>();

        PageHelper.startPage(page, limit);
        List<SyComment> all = commentMicrocircleService.Reception();

        PageInfo<SyComment> pageInfo = new PageInfo<>(all);

        PageResult<List> pageResult = new PageResult<>();
        pageResult.setMessage("成功");
        pageResult.setData(pageInfo.getList());
        pageResult.setState(0);
        pageResult.setTotal(pageInfo.getTotal());

        return pageResult;
    }
    /**
     *前端用户历史评论次数
     * */
    @RequestMapping("/countreception")
    public JsonResult<Integer> countByreceptione(){
        int a = commentMicrocircleService.countReception();

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /*
     *前端用户历史评论人数
     * */
    @RequestMapping("/countpeoplereception")
    public JsonResult<Integer> counttwoByreception(){
        int a = commentMicrocircleService.countPeopleReception();

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *前端用户今日评论次数
     * */
    @RequestMapping("/counttodayreception")
    public JsonResult<Integer> countthreeByreception(){
        Calendar calendar = Calendar.getInstance(); // get current instance of the calendar
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String b = formatter.format(calendar.getTime());
        int a = commentMicrocircleService.countTodayReception(b);

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *前端用户今日评论人数
     * */
    @RequestMapping("/counttodaypeoplereception")
    public JsonResult<Integer> countfourByreception(){
        Calendar calendar = Calendar.getInstance(); // get current instance of the calendar
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String b = formatter.format(calendar.getTime());
        int a = commentMicrocircleService.countTodayPeopleReception(b);

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *后台人员全部评论
     * @page:页数
     * @limit:条数
     * */
    @RequestMapping("/backstage")
    public PageResult<List> backstage(Integer page, Integer limit){

        PageHelper.startPage(page, limit);
        List<SyComment> all = commentMicrocircleService.Backstage();

        PageInfo<SyComment> pageInfo = new PageInfo<>(all);

        PageResult<List> pageResult = new PageResult<>();
        pageResult.setMessage("成功");
        pageResult.setData(pageInfo.getList());
        pageResult.setState(0);
        pageResult.setTotal(pageInfo.getTotal());

        return pageResult;
    }
    /**
     *后台人员历史评论次数
     * */
    @RequestMapping("/countbackstage")
    public JsonResult<Integer> countBybackstage(){
        int a = commentMicrocircleService.countBackstage();

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *后台人员历史评论人数
     * */
    @RequestMapping("/countpeoplebackstage")
    public JsonResult<Integer> counttwoBybackstage(){
        int a = commentMicrocircleService.countPeopleBackstage();

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *后台人员今日评论次数
     * */
    @RequestMapping("/counttodaybackstage")
    public JsonResult<Integer> countthreeBybackstage(){
        Calendar calendar = Calendar.getInstance(); // get current instance of the calendar
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String b = formatter.format(calendar.getTime());
        int a = commentMicrocircleService.countTodayBackstage(b);

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
    /**
     *后台人员今日评论人数
     * */
    @RequestMapping("/counttodaypeoplebackstage")
    public JsonResult<Integer> countfourBybackstage(){
        Calendar calendar = Calendar.getInstance(); // get current instance of the calendar
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String b = formatter.format(calendar.getTime());
        int a = commentMicrocircleService.countTodayPeopleBackstage(b);

        JsonResult<Integer> jsonResult = new JsonResult<>();
        jsonResult.setState(a);

        return jsonResult;
    }
}
